Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class com.pacist.diamonds.DrawnButton

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--com.pacist.diamonds.DiamondCanvas
                    |
                    +--com.pacist.diamonds.DrawnButton
Subclasses:
ArrowButton, FlexiButton, PolygonButton, RoundButton

public class DrawnButton
extends DiamondCanvas
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener
A button component which draws a border round itself. To draw anything in the button it must be subclassed.

See Also:
Serialized Form

Field Summary
boolean armed
          Holds Button's armed state.
byte behaviour
          Holds the current behaviour of the button.
static int BUTTON
          Button acts as a button.
java.util.Vector buttonListeners
           
byte flags
          Holds the notify flags.
static int LABEL
          Button acts as a label.
boolean mouseIn
          Internal mouse tracking variable - true if mouse is inside the Button component; false otherwise.
static int NOTIFY_ARM
          Notify all listeners when button is armed.
static int NOTIFY_DISARM
          Notify all listeners when button is disarmed.
static int RADIO
          Button acts as a radio button.
static int SHADOW_ALL
          Shadow all around.
static int SHADOW_BORDER
          Shadow on the border.
static int SHADOW_BOTTOM
          Shadow on bottom.
static int SHADOW_LEFT
          Shadow on left.
static int SHADOW_NONE
          No shadow.
static int SHADOW_RIGHT
          Shadow on right.
static int SHADOW_ROUNDED
          Rounded shadow.
static int SHADOW_TOP
          Shadow on top.
int shadowType
          Shadow used.
int state
          Current state.
int states
          Number of states.
static int TOGGLE
          Button acts as a toggle button.
boolean tracking
          Internal mouse tracking variable - true mouse has been pressed and held on button; false otherwise.
static int TRISTATE
          Button acts as a button, but has three different states.
java.lang.Object what
          Deprecated.  
 
Fields inherited from class com.pacist.diamonds.DiamondCanvas
tipText
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
DrawnButton()
          Creates and initializes a DrawnButton object, with the behaviour of a button.
DrawnButton(int behaviour)
          Creates and initializes a DrawnButton object, with the specified behaviour.
DrawnButton(java.lang.Object what)
          Deprecated.  
DrawnButton(java.lang.Object what, int behaviour)
          Deprecated.  
 
Method Summary
void addActionListener(java.awt.event.ActionListener l)
          Adds the specified action listener to receive action events from this button.
int getBehaviour()
          Returns current behaviour of button.
java.util.Vector getButtonListeners()
          Returns a Vector of all the current Button listeners.
int getNotify()
          Returns the notification flags.
int getShadowType()
          Returns the shadow type for the button.
int getState()
          Returns the current state.
boolean inButton(int x, int y)
          Determines whether a coordinate lies inside the button.
boolean isArmed()
          Determines whether the button is currently armed.
boolean isDown()
          Determines whether the button is down or not.
boolean isSet()
          Determines whether the button is set or not.
void mouseClicked(java.awt.event.MouseEvent event)
          Invoked when the mouse has been clicked on the DrawnButton.
void mouseDragged(java.awt.event.MouseEvent event)
          Invoked when a mouse button is pressed on the DrawnButton and then dragged.
void mouseEntered(java.awt.event.MouseEvent event)
          Invoked when the mouse enters the DrawnButton.
void mouseExited(java.awt.event.MouseEvent event)
          Invoked when the mouse exits the DrawnButton.
void mouseMoved(java.awt.event.MouseEvent event)
          Invoked when the mouse button has been moved on the DrawnButton (with no buttons no down).
void mousePressed(java.awt.event.MouseEvent event)
          Invoked when a mouse button has been pressed on a DrawnButton.
void mouseReleased(java.awt.event.MouseEvent event)
          Invoked when a mouse button has been released on the DrawnButton.
void paintButton(java.awt.Graphics g, boolean down)
          This method is called to redraw the button.
void paint(java.awt.Graphics g)
          This method is called to repaint this button.
void processAction()
          Processes action events occurring on this button by dispatching them to any registered ActionListener objects.
void removeActionListener(java.awt.event.ActionListener l)
          Removes the specified action listener so that it no longer receives action events from this button.
void setArmed(boolean b)
          Indicates if the button can be selected or not by the an input device (such as a mouse pointer).
void setBehaviour(int b)
          Sets the behaviour of the DrawnButton.
void set(boolean bSet)
          Sets the current state of the button.
void setEnabled(boolean b)
          Enables or disables this component, depending on the value of the parameter b.
void setNotify(int n)
          Returns the number of states.
void setShadowType(int t)
          Sets the shadow for the button.
void setState(int s)
          Sets the DrawnButton to the specified state.
void setStates(int n)
          Sets the number of states the DrawnButton has.
 
Methods inherited from class com.pacist.diamonds.DiamondCanvas
getTipText, mouseEnter, mouseExit, processMouseEvent, setTipText
 
Methods inherited from class java.awt.Canvas
addNotify, paint
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paint, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, print, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

LABEL

public static final int LABEL
Button acts as a label.

BUTTON

public static final int BUTTON
Button acts as a button.

TOGGLE

public static final int TOGGLE
Button acts as a toggle button.

TRISTATE

public static final int TRISTATE
Button acts as a button, but has three different states.

RADIO

public static final int RADIO
Button acts as a radio button.

SHADOW_NONE

public static final int SHADOW_NONE
No shadow.

SHADOW_LEFT

public static final int SHADOW_LEFT
Shadow on left.

SHADOW_RIGHT

public static final int SHADOW_RIGHT
Shadow on right.

SHADOW_TOP

public static final int SHADOW_TOP
Shadow on top.

SHADOW_BOTTOM

public static final int SHADOW_BOTTOM
Shadow on bottom.

SHADOW_ALL

public static final int SHADOW_ALL
Shadow all around.

SHADOW_BORDER

public static final int SHADOW_BORDER
Shadow on the border.

SHADOW_ROUNDED

public static final int SHADOW_ROUNDED
Rounded shadow.

NOTIFY_ARM

public static final int NOTIFY_ARM
Notify all listeners when button is armed.

NOTIFY_DISARM

public static final int NOTIFY_DISARM
Notify all listeners when button is disarmed.

behaviour

protected byte behaviour
Holds the current behaviour of the button.

flags

protected byte flags
Holds the notify flags.

states

protected int states
Number of states.

state

protected int state
Current state.

shadowType

protected int shadowType
Shadow used.

armed

protected boolean armed
Holds Button's armed state.

tracking

protected boolean tracking
Internal mouse tracking variable - true mouse has been pressed and held on button; false otherwise.

mouseIn

protected boolean mouseIn
Internal mouse tracking variable - true if mouse is inside the Button component; false otherwise.

what

protected java.lang.Object what
Deprecated. as of JDK1.1

buttonListeners

protected transient java.util.Vector buttonListeners
Constructor Detail

DrawnButton

public DrawnButton()
Creates and initializes a DrawnButton object, with the behaviour of a button.

DrawnButton

public DrawnButton(int behaviour)
Creates and initializes a DrawnButton object, with the specified behaviour.

DrawnButton

public DrawnButton(java.lang.Object what)
Deprecated. as of JDK1.1.

DrawnButton

public DrawnButton(java.lang.Object what,
                   int behaviour)
Deprecated. as of JDK1.1.
Method Detail

setBehaviour

public void setBehaviour(int b)
Sets the behaviour of the DrawnButton.
Parameters:
b - behaviour of button.

getBehaviour

public int getBehaviour()
Returns current behaviour of button.
Returns:
int - current behaviour.

setStates

public void setStates(int n)
Sets the number of states the DrawnButton has.
Parameters:
n - number of states.

setNotify

public void setNotify(int n)
Returns the number of states.
Parameters:
n - notification mask.
Returns:
int - the number of states. public int getStates() { return states; } /** Sets the notification flags.
See Also:
NOTIFY_ARM, NOTIFY_DISARM

getNotify

public int getNotify()
Returns the notification flags.
Returns:
int - the flag mask.

setState

public void setState(int s)
Sets the DrawnButton to the specified state.
Parameters:
s - new current state.

getState

public int getState()
Returns the current state.
Returns:
int - the current state.

set

public void set(boolean bSet)
Sets the current state of the button.
Parameters:
bSet - true puts button in state 1, false puts button in state 0.

isSet

public boolean isSet()
Determines whether the button is set or not.
Returns:
boolean - true if button is set; false otherwise.

isDown

public boolean isDown()
Determines whether the button is down or not.
Returns:
boolean - true if button is down; false otherwise.

setShadowType

public void setShadowType(int t)
Sets the shadow for the button.
See Also:
SHADOW_NONE

getShadowType

public int getShadowType()
Returns the shadow type for the button.
Returns:
int - the button's shadow type.

getButtonListeners

protected java.util.Vector getButtonListeners()
Returns a Vector of all the current Button listeners.
Returns:
Vector - all current Button listeners.

addActionListener

public void addActionListener(java.awt.event.ActionListener l)
Adds the specified action listener to receive action events from this button. Action events occur when a user presses or releases the mouse over this button.
Parameters:
l - the action listener.

removeActionListener

public void removeActionListener(java.awt.event.ActionListener l)
Removes the specified action listener so that it no longer receives action events from this button. Action events occur when a user presses or releases the mouse over this button.
Parameters:
l - the action listener.

processAction

public void processAction()
Processes action events occurring on this button by dispatching them to any registered ActionListener objects.

This method is not called unless action events are enabled for this button. Action events are enabled when one of the following occurs:


paintButton

public void paintButton(java.awt.Graphics g,
                        boolean down)
This method is called to redraw the button. Most applications that subclass DrawnButton should override this method.
Parameters:
g - the graphics context.
down - true if button is currently held down; false otherwise.

paint

public void paint(java.awt.Graphics g)
This method is called to repaint this button.
Parameters:
g - the graphics context.
Overrides:
paint in class java.awt.Canvas

setEnabled

public void setEnabled(boolean b)
Enables or disables this component, depending on the value of the parameter b. An enabled component can respond to user input and generate events. Components are enabled initially by default. Enables or disables this component, depending on the value of the parameter b. An enabled component can respond to user input and generate events. Components are enabled initially by default.
Parameters:
b - If true, this component is enabled; otherwise this component is disabled.
Overrides:
setEnabled in class java.awt.Component

inButton

public boolean inButton(int x,
                        int y)
Determines whether a coordinate lies inside the button.
Parameters:
x - the x coordinate.
y - the y coordinate.
Returns:
boolean - true if the given coordinates lie within the button; false otherwise.

setArmed

public void setArmed(boolean b)
Indicates if the button can be selected or not by the an input device (such as a mouse pointer).
Parameters:
b - true to "Arm" the button; false otherwise.

isArmed

public boolean isArmed()
Determines whether the button is currently armed.
Returns:
boolean - true if button is armed; false otherwise.
See Also:
setArmed(boolean)

mousePressed

public void mousePressed(java.awt.event.MouseEvent event)
Invoked when a mouse button has been pressed on a DrawnButton.
Specified by:
mousePressed(java.awt.event.MouseEvent) in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent event)
Invoked when a mouse button has been released on the DrawnButton.
Specified by:
mouseReleased(java.awt.event.MouseEvent) in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent event)
Invoked when the mouse enters the DrawnButton.
Specified by:
mouseEntered(java.awt.event.MouseEvent) in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent event)
Invoked when the mouse exits the DrawnButton.
Specified by:
mouseExited(java.awt.event.MouseEvent) in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent event)
Invoked when a mouse button is pressed on the DrawnButton and then dragged.
Specified by:
mouseDragged(java.awt.event.MouseEvent) in interface java.awt.event.MouseMotionListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent event)
Invoked when the mouse has been clicked on the DrawnButton.
Specified by:
mouseClicked(java.awt.event.MouseEvent) in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent event)
Invoked when the mouse button has been moved on the DrawnButton (with no buttons no down).
Specified by:
mouseMoved(java.awt.event.MouseEvent) in interface java.awt.event.MouseMotionListener

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD